package student.aistar.day04;

import java.util.Arrays;

/**
 * 二维数组的使用
 */
public class TwoArrDemo {
    public static void main(String[] args) {
        int[][] arr = {{1,2},{2,3},{3,4}};
        System.out.println(arr.length);

        for (int i = 0; i < arr.length; i++) {
            System.out.println(Arrays.toString(arr[i]));
        }

        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                System.out.print(arr[i][j]+"\t");
            }
            System.out.println();
        }
        System.out.println(Arrays.deepToString(arr));

        for (int[] ints : arr) {
            for (int anInt : ints) {
                System.out.print(anInt+"\t");
            }
            System.out.println();
        }

        //arr[0] = {1,1} //error
        //一行一行赋值
        arr[0] = new int[]{1,2,3};

        String[][] arr1 = new String[4][6];

        arr1[0]=new String[]{"白","日","依","山","尽",","};
        arr1[1]=new String[]{"黄","河","入","海","流","."};
        arr1[2]=new String[]{"欲","穷","千","里","目",","};
        arr1[3]=new String[]{"更","上","一","层","楼",","};

        String[][] arr2 = new String[6][4];
        int i = 0;
        for (String[] strings : arr1) {
            int j = 0;
            for (String string : strings) {
                arr2[j++][i] = string;
            }
            i++;
        }

        System.out.println(Arrays.deepToString(arr2));


    }
}
